#include <iostream>
#include<windows.h>
#include "main.h"

ULONG64 pte_base = 0xFFFFF20000000000;


int main() {

	GetPteAddress(0x72160000);
	getPte(0x72160000);

	return 0;
}

PULONG64 GetPteAddress(ULONG64 addr) {
	ULONG64 temp = 0;
	temp = (ULONG64)addr & 0xffffffffffff;
	printf("GetPteAddress:  temp: 0x%llX\n", temp);
	temp = temp >> 12;
	printf("GetPteAddress:  temp: 0x%llX\n", temp);
	temp = temp << 3;
	printf("GetPteAddress:  temp: 0x%llX\n", temp);
	temp = temp + (ULONG64)pte_base;
	printf("GetPteAddress:  temp: 0x%llX\n", temp);
	return (PULONG64)(((((ULONG64)addr & 0xffffffffffff) >> 12) << 3) + pte_base);
}

ULONG64 getPte(ULONG64 VirtualAddress) {

	ULONG64 temp = VirtualAddress >> 9;
	printf("getPte:  temp: 0x%llX\n", temp);
	temp = temp & 0x7FFFFFFFF8;
	printf("getPte:  temp: 0x%llX\n", temp);
	temp = temp + pte_base;
	printf("getPte:  temp: 0x%llX\n", temp);
	return ((VirtualAddress >> 9) & 0x7FFFFFFFF8) + pte_base;
}